package cn.iocoder.yudao.module.book.controller.app.voice;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.book.controller.admin.voice.vo.VoicePageReqVO;
import cn.iocoder.yudao.module.book.controller.app.voice.vo.AppVoiceRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.voice.VoiceDO;
import cn.iocoder.yudao.module.book.service.voice.VoiceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 音频")
@RestController
@RequestMapping("/user/recording")
public class AppVoiceController {

    @Resource
    private VoiceService voiceService;

    @GetMapping("/list")
    @Operation(summary = "获得音频分页")
    public CommonResult<PageResult<AppVoiceRespVO>> getVoicePage(@Valid VoicePageReqVO pageReqVO) {
        PageResult<VoiceDO> pageResult = voiceService.getVoicePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppVoiceRespVO.class));
    }
}